package com.evan.wj.dao;

import com.evan.wj.pojo.Node;
import com.evan.wj.pojo.ViewNode;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface NodeDao extends JpaRepository<Node,Integer> {

    @Query(value = "select new com.evan.wj.pojo.ViewNode(n , b ) from Node n, Book b where n.bookId = b.id and n.userId = ?1")
    List<ViewNode> findPersonalViewNode( Integer ui);

    @Query(value = "select new com.evan.wj.pojo.ViewNode(n , b ) from Node n, Book b where n.bookId = b.id and n.userId = ?1 and b.category.id = ?2")
    List<ViewNode> findPersonalViewNode( Integer userId,Integer cid);


    @Query(value = "select new com.evan.wj.pojo.ViewNode(n , b ) from Node n, Book b where n.bookId = b.id ")
    List<ViewNode> findAllViewNode();
}
